package com.basic.auth.domain;


import com.basic.auth.controller.req.AuthFuncReqForm;
import com.basic.auth.controller.res.AuthFuncResForm;
import com.basic.auth.dao.model.AuthFunc;
import com.basic.common.bean.BeanCopierDsUtil;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lpp
 * @version 1.0
 * @Date 2018/8/24 17:54
 */
public class AuthFuncBo extends AuthFunc {

    /**
     * 层级串模糊查询
     *
     * @author lpp
     * @date 2019/8/21 10:58
     */
    private String axisLike;
    /**
     * 授权人boId
     *
     * @author
     * @date  15:05
     */
    private String authBoId;
    /**
     * 子级功能集合
     */
    private List<AuthFuncBo> subFuncList;
    /**
     * 功能id集合
     */
    private List<Long> funcIdList;
    /**
     * 是否被选中
     */
    private Integer isChecked;
    /**
     * 多角色code,用“|”分割
     */
    private String roleCodes;
    /**
     * 被授权用户id
     */
    private String boId;
    /**
     * 用户类型
     */
    private String userType;
    /**
     * 用户类型(模糊查)
     */
    private String userTypeLike;
    /**
     * 业务类型
     */
    private String busType;
    /**
     * 业务id
     */
    private String busId;
    /**
     * 多个子系统id用‘|’分割
     */
    private String subSystemIds;
    private Integer pageNum;
    private Integer pageSize;
    /**
     * 类型集合
     */
    private List<String> typeList;
    /**
     * 编码CODE集合
     */
    private List<String> codeList;
    /**
     * 编码排除CODE集合
     */
    private List<String> codeNotInList;
    /**
     * 父级节点CODE
     */
    private String parentFuncCode;

    public String getParentFuncName() {
        return parentFuncName;
    }

    public void setParentFuncName(String parentFuncName) {
        this.parentFuncName = parentFuncName;
    }

    /**
     * 父级节点Name
     */
    private String parentFuncName;
    /**
     * 父级节点ID集合
     */
    private List<Long> parentFuncIdList;

    public String getAxisLike() {
        return axisLike;
    }

    public void setAxisLike(String axisLike) {
        this.axisLike = axisLike;
    }

    public String getAuthBoId() {
        return authBoId;
    }

    public void setAuthBoId(String authBoId) {
        this.authBoId = authBoId;
    }

    public List<AuthFuncBo> getSubFuncList() {
        return subFuncList;
    }

    public void setSubFuncList(List<AuthFuncBo> subFuncList) {
        this.subFuncList = subFuncList;
    }

    public List<Long> getFuncIdList() {
        return funcIdList;
    }

    public void setFuncIdList(List<Long> funcIdList) {
        this.funcIdList = funcIdList;
    }

    public Integer getIsChecked() {
        return isChecked;
    }

    public void setIsChecked(Integer isChecked) {
        this.isChecked = isChecked;
    }

    public String getRoleCodes() {
        return roleCodes;
    }

    public void setRoleCodes(String roleCodes) {
        this.roleCodes = roleCodes;
    }

    public String getBoId() {
        return boId;
    }

    public void setBoId(String boId) {
        this.boId = boId;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public String getUserTypeLike() {
        return userTypeLike;
    }

    public void setUserTypeLike(String userTypeLike) {
        this.userTypeLike = userTypeLike;
    }

    public String getBusType() {
        return busType;
    }

    public void setBusType(String busType) {
        this.busType = busType;
    }

    public String getBusId() {
        return busId;
    }

    public void setBusId(String busId) {
        this.busId = busId;
    }

    public String getSubSystemIds() {
        return subSystemIds;
    }

    public void setSubSystemIds(String subSystemIds) {
        this.subSystemIds = subSystemIds;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List<String> getTypeList() {
        return typeList;
    }

    public void setTypeList(List<String> typeList) {
        this.typeList = typeList;
    }

    public List<String> getCodeList() {
        return codeList;
    }

    public void setCodeList(List<String> codeList) {
        this.codeList = codeList;
    }

    public String getParentFuncCode() {
        return parentFuncCode;
    }

    public void setParentFuncCode(String parentFuncCode) {
        this.parentFuncCode = parentFuncCode;
    }

    public List<Long> getParentFuncIdList() {
        return parentFuncIdList;
    }

    public void setParentFuncIdList(List<Long> parentFuncIdList) {
        this.parentFuncIdList = parentFuncIdList;
    }

    public List<String> getCodeNotInList() {
        return codeNotInList;
    }

    public void setCodeNotInList(List<String> codeNotInList) {
        this.codeNotInList = codeNotInList;
    }

    @Override
    public String toString() {
        return "AuthFuncBo{" +
                "authBoId=" + authBoId +
                ", subFuncList=" + subFuncList +
                ", funcIdList=" + funcIdList +
                ", isChecked=" + isChecked +
                ", roleCodes='" + roleCodes + '\'' +
                ", boId=" + boId +
                ", userType='" + userType + '\'' +
                ", userTypeLike='" + userTypeLike + '\'' +
                ", busType='" + busType + '\'' +
                ", busId='" + busId + '\'' +
                ", subSystemIds='" + subSystemIds + '\'' +
                ", pageNum=" + pageNum +
                ", pageSize=" + pageSize +
                ", typeList=" + typeList +
                ", codeList=" + codeList +
                ", codeNotInList=" + codeNotInList +
                '}';
    }

    public static AuthFuncBo reqToBo(AuthFuncReqForm reqForm){
        if(reqForm == null){
            return null;
        }
        AuthFuncBo authFuncBo = BeanCopierDsUtil.copyProperties(reqForm, AuthFuncBo.class);
        return authFuncBo;
    }

    public static List<AuthFuncResForm> boToListRes(List<AuthFuncBo> authFuncBoList) {
        List<AuthFuncResForm> authFuncResFormList = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(authFuncBoList)) {
            for (AuthFuncBo authFuncBo : authFuncBoList) {
                AuthFuncResForm authFuncResForm = BeanCopierDsUtil.copyProperties(authFuncBo, AuthFuncResForm.class);
                List<AuthFuncBo> subFuncList = authFuncBo.getSubFuncList();
                if (CollectionUtils.isNotEmpty(subFuncList)) {
                    List<AuthFuncResForm> authFuncResForms = BeanCopierDsUtil.copyPropertiesOfList(subFuncList, AuthFuncResForm.class);
                    authFuncResForm.setSubFuncList(authFuncResForms);
                    authFuncResFormList.add(authFuncResForm);
                }
            }
        }
        return authFuncResFormList;
    }
}
